#使用openai的代码风格调用ollama

from openai import OpenAI

client = OpenAI(base_url="http://localhost:11434/v1/",api_key="ollama")

chat_completion = client.chat.completions.create(
    messages=[{"role":"user","content":"你好，请介绍下自己"}],model="llama3"
)

print(chat_completion.choices[0])